package com.chy.mybatis.plugin;

import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 功能：
 * <p>
 * ──────────────────────────────────────────
 * version  变更日期       修改人    修改说明
 * ------------------------------------------
 * V1.0.0   2022/3/10     CHY     初版
 * ──────────────────────────────────────────
 */
@Configuration
public class MyPluginConfig {

    @Bean
    public MyPlugin myPlugin(){
        MyPlugin myPlugin = new MyPlugin();
        return myPlugin;
    }

    @Bean
    public ConfigurationCustomizer configurationCustomizer(){
        return new ConfigurationCustomizer() {

            @Override
            public void customize(org.apache.ibatis.session.Configuration configuration) {
                configuration.setMapUnderscoreToCamelCase(true);
                configuration.addInterceptor(myPlugin());
            }
        };
    }
}
